<template>
	<view>
		<view class="inputs_info">
			<view class="ipt">
				<input v-model="text" @confirm='inputs' class="inputs" confirm-type="search" type="text" placeholder="大家都在搜" />
				<uni-icons type="search" size="24" color="#888888"></uni-icons>
			</view>
		</view>
		<view class="tit">
			<view class="cont_flex page_width">
				<view class="flex_item" v-for="(item,index) in businessList" :key="index" @click="goPage(item)">
					<image :src="item.typeHead" mode=""></image>
					<view class="text">{{item.typeName}}</view>
				</view>
			</view>
			<uni-load-more v-if="!businessList.length <= 0" :status="statusshow"></uni-load-more>
		</view>
		<kong v-if="businessList.length == 0"></kong>
	</view>
</template>

<script>
	import {
		getCompanyList
	} from '@/common/http.api.js';
	export default {
		data() {
			return {
				params: {
					pageNum: 1,
					pageSize: 20,
					parentId: 0
				},
				businessList: [],
				text:'',
				statusshow:'loading'
			};
		},
		onLoad(e) {
			this.params.parentId = e.id
			this.getList()
		},
		methods:{
			inputs(e){
				uni.navigateTo({
					url:`/pages/business/search?textinfo=${e.detail.value}`
				})
				this.text = ''
			},
			getList(){
				getCompanyList(this.params).then(res=>{
					this.businessList.push(...res.rows)
					if(this.businessList.length == res.total){
						this.statusshow = 'no-more'
					}
				})
			},
			onReachBottom(){
				this.params.pageNum ++ 
				this.getList()
			},
			goPage(item){
				uni.navigateTo({
					url:`/pages/business/businessInfo?id=${item.id}`
				})
			}
		}
	}
</script>

<style lang="less">
	page {
		background-color: #F0F0F1;
	}

	.tit {
		margin-top: 30rpx;

		.cont_flex {
			display: flex;
			margin: 0rpx auto;
			flex-wrap: wrap;
			text-align: center;
			width: 716rpx;
			gap: 20rpx;

			.flex_item {
				width: 225rpx;
				height: 240rpx;
				background-color: #fff;
				margin-bottom: 28rpx;

				image {
					width: 100%;
					height: 160rpx;
				}

				.text {
					width: 200rpx;
					font-size: 30rpx;
					line-height: 60rpx;
					white-space: nowrap;
					overflow: hidden;
					margin: 0 auto;
				}
			}
		}
	}
</style>